﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ykglxt
{
    public partial class Form_YPBM_Set : Form
    {
        DataGridViewRow dgvrChange;
        public Form_YPBM_Set(DataGridViewRow dgvr)
        {
            InitializeComponent();
            tbxYPBM.Text = dgvr.Cells[1].Value.ToString();
            tbxZJF.Text = dgvr.Cells[2].Value.ToString();
            tbxYPMC.Text = dgvr.Cells[3].Value.ToString();
            tbxSPMC.Text = dgvr.Cells[4].Value.ToString();
            tbxYLDW.Text = dgvr.Cells[12].Value.ToString();
            tbxJLDW.Text = dgvr.Cells[6].Value.ToString();
            tbxJL.Text = dgvr.Cells[14].Value.ToString();
            tbxBZDW.Text = dgvr.Cells[8].Value.ToString();
            tbxBZ.Text = dgvr.Cells[13].Value.ToString();
            tbxGG.Text = dgvr.Cells[5].Value.ToString();
            tbxYBBZ.Text = dgvr.Cells[20].Value.ToString();
            cbxYPTJLB.SelectedValue = dgvr.Cells[19].Value.ToString();
            cbxYF.SelectedValue = dgvr.Cells[17].Value.ToString();
            cbxCS.SelectedValue = dgvr.Cells[18].Value.ToString();
            tbxDJ.Text = dgvr.Cells[7].Value.ToString();
            tbxBZDJ.Text = dgvr.Cells[9].Value.ToString();
            cbxJX.SelectedValue = dgvr.Cells[21].Value.ToString();
            tbxYPBZ.Text = dgvr.Cells[11].Value.ToString();
            cbxMZFYLB.SelectedValue = dgvr.Cells[16].Value.ToString();
            cbxZYFYLB.SelectedValue = dgvr.Cells[15].Value.ToString();
            lblJLGG.Text = tbxYLDW.Text.Trim() + lblJLGG.Text.Trim() + tbxJLDW.Text.Trim();
            lblBZGG.Text = tbxJLDW.Text.Trim() + lblBZGG.Text.Trim() + tbxBZDW.Text.Trim();
            dgvrChange = new DataGridViewRow();
            dgvrChange = dgvr;
        }

        void allClear()
        {
            tbxYPBM.Clear();
            tbxZJF.Clear();
            tbxYPMC.Clear();
            tbxSPMC.Clear();
            tbxYLDW.Clear();
            tbxJLDW.Clear();
            tbxJL.Clear();
            tbxBZDW.Clear();
            tbxBZ.Clear();
            tbxGG.Clear();
            tbxYBBZ.Clear();
            tbxDJ.Clear();
            tbxBZDJ.Clear();
            tbxYPBZ.Clear();
        }

        private void Form_YPBM_Set_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“yKGLXTDataSet.Dic_FYLB”中。您可以根据需要移动或移除它。
            this.dic_FYLBTableAdapter.Fill(this.yKGLXTDataSet.Dic_FYLB);
            // TODO: 这行代码将数据加载到表“yKGLXTDataSet.Dic_YPJX”中。您可以根据需要移动或移除它。
            this.dic_YPJXTableAdapter.Fill(this.yKGLXTDataSet.Dic_YPJX);
            // TODO: 这行代码将数据加载到表“yKGLXTDataSet.Dic_CS”中。您可以根据需要移动或移除它。
            this.dic_CSTableAdapter.Fill(this.yKGLXTDataSet.Dic_CS);
            // TODO: 这行代码将数据加载到表“yKGLXTDataSet.Dic_YF”中。您可以根据需要移动或移除它。
            this.dic_YFTableAdapter.Fill(this.yKGLXTDataSet.Dic_YF);
            // TODO: 这行代码将数据加载到表“yKGLXTDataSet.Dic_YPTJLB”中。您可以根据需要移动或移除它。
            this.dic_YPTJLBTableAdapter.Fill(this.yKGLXTDataSet.Dic_YPTJLB);
            // TODO: 这行代码将数据加载到表“yKGLXTDataSet.Dic_SCS”中。您可以根据需要移动或移除它。
            this.dic_SCSTableAdapter.Fill(this.yKGLXTDataSet.Dic_SCS);
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            if(MessageBox.Show("确认不保存？","提醒",MessageBoxButtons.OKCancel,MessageBoxIcon.Information) == DialogResult.OK)
                this.Close();
        }

        private void Form_YPBM_Set_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                e.Handled = true;
                SendKeys.Send("{TAB}");
            }
        }

        private void tbxYLDW_Validated(object sender, EventArgs e)
        {
            lblJLGG.Text = "/";
            lblJLGG.Text = tbxYLDW.Text.Trim() + lblJLGG.Text.Trim() + tbxJLDW.Text.Trim();
        }

        private void tbxJLDW_Validated(object sender, EventArgs e)
        {
            lblJLGG.Text = "/";
            lblJLGG.Text = tbxYLDW.Text.Trim() + lblJLGG.Text.Trim() + tbxJLDW.Text.Trim();
        }

        private void tbxBZDW_Validated(object sender, EventArgs e)
        {
            lblBZGG.Text = "/";
            lblBZGG.Text = tbxJLDW.Text.Trim() + lblBZGG.Text.Trim() + tbxBZDW.Text.Trim();
        }

        private void tbxBZ_Validated(object sender, EventArgs e)
        {
            tbxGG.Text = "";
            tbxGG.Text = tbxJL.Text.Trim() + tbxYLDW.Text.Trim() + "×" + tbxBZ.Text.Trim() + tbxJLDW.Text.Trim() +'/' + tbxBZDW.Text.Trim();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            dgvrChange.Cells[1].Value = tbxYPBM.Text.Trim();
            dgvrChange.Cells[2].Value = tbxZJF.Text.Trim();
            dgvrChange.Cells[3].Value = tbxYPMC.Text.Trim() ;
            dgvrChange.Cells[4].Value = tbxSPMC.Text.Trim();
            dgvrChange.Cells[12].Value = tbxYLDW.Text.Trim();
            dgvrChange.Cells[6].Value = tbxJLDW.Text.Trim();
            dgvrChange.Cells[14].Value = tbxJL.Text.Trim();
            dgvrChange.Cells[8].Value = tbxBZDW.Text.Trim();
            dgvrChange.Cells[13].Value = tbxBZ.Text.Trim();
            dgvrChange.Cells[5].Value = tbxGG.Text.Trim();
            dgvrChange.Cells[20].Value = tbxYBBZ.Text.Trim();
            dgvrChange.Cells[19].Value = cbxYPTJLB.SelectedValue.ToString().Trim();
            dgvrChange.Cells[17].Value = cbxYF.SelectedValue.ToString().Trim();
            dgvrChange.Cells[18].Value = cbxCS.SelectedValue.ToString().Trim();
            dgvrChange.Cells[7].Value = tbxDJ.Text.Trim();
            dgvrChange.Cells[9].Value = tbxBZDJ.Text.Trim();
            dgvrChange.Cells[21].Value = cbxJX.SelectedValue.ToString().Trim();
            dgvrChange.Cells[11].Value = tbxYPBZ.Text.Trim();
            dgvrChange.Cells[16].Value = cbxMZFYLB.SelectedValue.ToString().Trim();
            dgvrChange.Cells[15].Value = cbxZYFYLB.SelectedValue.ToString().Trim();
            dgvrChange.Cells[10].Value = cbxSCCS.SelectedValue.ToString().Trim();
            this.Close();
        }
    }
}
